#!/bin/sh
# This file is part of cloud-init. See LICENSE file for license information.

# This script is used on non-systemd systems. It is called by the
# cloud-init-hotplug init.d script.
#
# Creates a named pipe and then continually listens to this pipe. The pipe
# is written to by the hook-hotplug script (which is called by a udev rule
# upon a network device event). Anything received via the pipe is then
# passed on via the "cloud-init devel hotplug-hook handle" command.

PIPE="/run/cloud-init/hook-hotplug-cmd"

mkfifo -m700 $PIPE

while true; do
  # shellcheck disable=SC2162
  read args < $PIPE
  # shellcheck disable=SC2086
  exec /usr/bin/cloud-init devel hotplug-hook $args
done

exit
